/*
    Copyright (c) 2008-2009, Prashanta Shrestha All Rights Reserved.
    Available under GNU Lesser General Public License >= 3.0 as published by the Free Software Foundation.
    see <http://www.gnu.org/licenses/>
*/
/*-------------------------------------------------------------------------------------
  CLASS : qDojo.dijix.Rounded
  ==================================
  - Rounded corner using image. 
  - Thanks to - http://dojocampus.org/content/2008/03/21/no-end-to-rounded-corners/
  -------------------------------------------------------------------------------------*/
dojo.provide("qDojo.dijix.Rounded");

dojo.require("dijit._Widget");
dojo.require("dijit._Templated");

dojo.declare("qDojo.dijix.Rounded", [dijit._Widget, dijit._Templated], {
	templatePath: dojo.moduleUrl("qDojo.dijix", "template/Rounded.html"),
	
	bgImg: "",		// standard background image (png)
	bgImgAlt: "",	// background image for ie6
	bgType: 0,
	content: "",
	
	postCreate: function() 
	{				
		// removed after encountered problem with IE when programmatically creating this widget
		// dojo.style(this.contentNode, "height" , dojo.style(this.outerNode, "height")-10+'px'); // TODO: Calculate correct height						

		var alt = (this.bgImgAlt.length && dojo.isIE < 7);
		var path = dojo.moduleUrl("qDojo.dijix.resources.images"); 
		
		switch(this.bgType)
		{
			case 0:	this.bgImg 	  = path+"RoundedBg.png";	this.bgImgAlt = path+"RoundedBg.gif"; 	break;
			case 1:	this.bgImg 	  = path+"RoundedLight.png";this.bgImgAlt = path+"RoundedLight.gif";	break;
			case 2:	this.bgImg 	  = path+"RoundedBg3.png";this.bgImgAlt = path+"RoundedBg3.png";	break;
		}
		dojo.forEach(["roundedContent","roundedTop","roundedBottom","roundedBottomDiv"],
			function(elName){
				dojo.style(this[elName],"backgroundImage", "url(" + (alt ? this.bgImgAlt : this.bgImg)  + ")");
			},
		this);	
		if(this.content)
			this.containerNode.innerHTML = this.content;
	}
});